import { createApp } from "vue"

import Loading from "./Loading.vue"

export default {
  loading: null,
  install(app) {
    if (this.loading) {
      // 防止多次载入
      app.config.globalProperties.$loading = this.loading
      return
    }
    
    // 创建Loading组件的实例
    let instance = createApp(Loading)
    let div = document.createElement("div")
    let body = document.body

    body.appendChild(div)
    this.loading = instance.mount(div)

    app.config.globalProperties.$loading = this.loading;
  }
}